package com.eliza.base.views.component.progress

import android.util.Log
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.AssistChip
import androidx.compose.material3.AssistChipDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.InputChip
import androidx.compose.material3.InputChipDefaults
import androidx.compose.material3.SuggestionChip
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.navigation.NavController

/*
*
* Assist: Guides the user during a task. Often appears as a temporary UI element in response to user input.
Filter: Allows users to refine content from a set of options. They can be selected or deselected, and may include a checkmark icon when selected.
Input: Represents user-provided information, such as selections in a menu. They can contain an icon and text, and provide an 'X' for removal.
Suggestion: Provides recommendations to the user based on their recent activity or input. Typically appear beneath an input field to prompt user actions.
*
* 辅助：在任务期间指导用户。通常显示为响应用户输入的临时 UI 元素。
筛选器：允许用户从一组选项中优化内容。可以选择或取消选择它们，并且在选中时可能包含复选标记图标。
输入：表示用户提供的信息，例如菜单中的选择。它们可以包含图标和文本，并提供用于删除的“X”。
建议：根据用户最近的活动或输入向用户提供建议。通常显示在输入字段下方，以提示用户操作。
* */
object ChipsX {
    @Composable
    fun Show(navController: NavController) {
        Column {
            SuggestionChip(
                onClick = { Log.d("Suggestion chip", "hello world") },
                label = { Text("Suggestion chip") }
            )
            AssistChip(
                onClick = { Log.d("Assist chip", "hello world") },
                label = { Text("Assist chip") },
                leadingIcon = {
                    Icon(
                        Icons.Filled.Settings,
                        contentDescription = "Localized description",
                        Modifier.size(AssistChipDefaults.IconSize)
                    )
                }
            )
            FilterChipExample()
            InputChipExample("InputChipExample") {

            }
        }
    }

    @Composable
    private fun FilterChipExample() {
        var selected by remember { mutableStateOf(false) }

        FilterChip(
            onClick = { selected = !selected },
            label = {
                Text("Filter chip")
            },
            selected = selected,
            leadingIcon = if (selected) {
                {
                    Icon(
                        imageVector = Icons.Filled.Done,
                        contentDescription = "Done icon",
                        modifier = Modifier.size(FilterChipDefaults.IconSize)
                    )
                }
            } else {
                null
            },
        )
    }

    @Composable
    private fun InputChipExample(
        text: String,
        onDismiss: () -> Unit,
    ) {
        var enabled by remember { mutableStateOf(true) }
        if (!enabled) return

        InputChip(
            onClick = {
                onDismiss()
                enabled = !enabled
            },
            label = { Text(text) },
            selected = enabled,
            avatar = {
                Icon(
                    Icons.Filled.Person,
                    contentDescription = "Localized description",
                    Modifier.size(InputChipDefaults.AvatarSize)
                )
            },
            trailingIcon = {
                Icon(
                    Icons.Default.Close,
                    contentDescription = "Localized description",
                    Modifier.size(InputChipDefaults.AvatarSize)
                )
            },
        )
    }
}
